package com.Alan;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;

import java.util.Map;

public class test {
    public void fun() {
        String myJsonObj2 = "{\n" +
                "    \"name\":\"网站\",\n" +
                "    \"num\":3,\n" +
                "    \"sites\": [\n" +
                "        { \"name\":\"Google\", \"info\":[ \"Android\", \"Google 搜索\", \"Google 翻译\" ] },\n" +
                "        { \"name\":\"Runoob\", \"info\":[ \"菜鸟教程\", \"菜鸟工具\", \"菜鸟微信\" ] },\n" +
                "        { \"name\":\"Taobao\", \"info\":[ \"淘宝\", \"网购\" ] }\n" +
                "    ]\n" +
                "}";
        //将json字符串转换成jsonObject对象
        JSONObject jsonObject = JSON.parseObject(myJsonObj2);
        System.out.println(jsonObject.get("sites").getClass().toString());
        String sites = jsonObject.getString("sites");
        sites = sites.substring(1, sites.length() - 1);
//        System.out.println(JSON.parseO(sites));
        System.out.println(jsonObject.getJSONArray("sites").getClass().toString());
//        Map<String, String> map = (Map<String, String>) jsonObject.("sites");
//        System.out.println(map.get("Google"));
    }

    @Test
    public void t(){
        fun();
    }
}
